Skip to content

FEAT(backend): initial backend setup and dependencies#133

Merged
Saahi30 merged 3 commits intodevfrom
backend-setup
Nov 1, 2025
Merged

FEAT(backend): initial backend setup and dependencies#133
Saahi30 merged 3 commits intodevfrom
backend-setup

Conversation

@Saahi30
Copy link
Contributor

@Saahi30 Saahi30 commented Nov 1, 2025

📝 Description

This pull request sets up the backend folder for the InPactAI project. It includes initial FastAPI app structure, environment configuration, and dependency management.

🔧 Changes Made

  • Added FastAPI backend application files
  • Created requirements.txt for Python dependencies
  • Added environment variable template
  • Set up basic backend folder structure

✅ Checklist

  • I have read the contributing guidelines.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if applicable).
  • Any dependent changes have been merged and published in downstream modules.

Summary by CodeRabbit

  • New Features

    • Backend API with welcome endpoint now available
    • CORS middleware configured for cross-origin requests from http://localhost:3000
    • Environment-based configuration system for database and API credentials
  • Documentation

    • Added backend project structure and setup documentation
  • Chores

    • Added Python dependencies for FastAPI backend
    • Added environment variable configuration example
    • Updated gitignore for development tools and environment files

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 1, 2025

Walkthrough

Establishes foundational backend project structure with Python package initialization files, a FastAPI application configured with CORS middleware, Pydantic-based settings management, environment variable configuration, database connection placeholders, required dependencies, and supporting documentation and git configuration.

Changes

Cohort / File(s) Summary
Backend Documentation & Git Configuration
backend/README.md, .gitignore
Adds backend project README documenting structure and setup; updates gitignore to exclude .vscode/, .env files, and .next/ directory
Package Initialization
backend/app/__init__.py, backend/app/api/__init__.py, backend/app/api/routes/__init__.py, backend/app/core/__init__.py, backend/app/db/__init__.py, backend/app/models/__init__.py
Establishes Python package namespace with minimal initialization markers across app structure layers
Configuration Setup
backend/app/core/config.py, backend/env_example
Introduces Pydantic Settings class with database_url and ai_api_key fields; provides example environment file with database, API key, and CORS origin placeholders
FastAPI Application
backend/app/main.py
Creates FastAPI instance with CORS middleware (allowing localhost:3000) and root GET endpoint returning welcome message
Database Layer
backend/app/db/database.py
Adds database module placeholder for connection setup logic
Dependencies
backend/requirements.txt
Declares 23 Python package dependencies (fastapi, uvicorn, pydantic, pydantic-settings, sqlalchemy, and supporting libraries)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • backend/app/core/config.py: Verify Pydantic Settings configuration aligns with environment variable naming conventions and expected types
  • backend/app/main.py: Confirm CORS middleware configuration, origin defaults, and endpoint implementation are secure and appropriate
  • backend/requirements.txt: Review pinned versions and compatibility (pydantic-settings uses >= constraint while others use exact pins)

Poem

🐰 A backend burrows deep, with packages in a stack,
FastAPI stands ready, with CORS watching its back,
From config to database, the structure takes its form,
Environment variables ready to weather any storm! 🚀✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "FEAT(backend): initial backend setup and dependencies" directly summarizes the primary changes in the pull request. The changeset establishes the foundational backend infrastructure including FastAPI application structure, package organization with initializers, configuration management via pydantic Settings, dependency declarations in requirements.txt, and environment configuration templates. The title accurately captures both the scope (backend) and the main purpose (initial setup and dependencies), making it clear to reviewers that this is the inaugural backend infrastructure commit. The title is concise, specific, and free from vague terminology.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch backend-setup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Saahi30
Copy link
Contributor Author

Saahi30 commented Nov 1, 2025

@CodeRabbit review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 1, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (10)
backend/app/__init__.py (1)

1-1: Consider removing the placeholder comment or adding actual initialization code.

Python __init__.py files are typically either empty (for namespace packages) or contain imports/initialization logic. A comment-only file is unusual and doesn't serve a functional purpose.

Apply this diff to make it an empty file:

-# app package init

Alternatively, if you plan to expose specific modules or functions from the app package, you could add imports here, for example:

from app.main import app

__all__ = ["app"]
backend/README.md (1)

1-3: Expand the README with actual setup instructions.

The README currently only contains a placeholder description. Since this PR introduces FastAPI setup, environment configuration, and dependencies, the README should include practical setup instructions such as:

  • Prerequisites and dependencies
  • Environment setup steps
  • How to install requirements
  • How to run the application
  • Configuration details

Would you like me to generate a comprehensive README template with setup instructions for the FastAPI backend?

backend/app/api/routes/__init__.py (1)

1-1: Consider removing the placeholder comment.

Similar to other __init__.py files in this PR, this comment-only file is not idiomatic Python. The file should either be empty or contain actual initialization code such as route imports.

Apply this diff to make it an empty file:

-# routes package init
backend/app/db/database.py (1)

1-1: Placeholder for database connection setup.

This file currently contains only a comment. Since the PR introduces DATABASE_URL in the configuration (backend/app/core/config.py as mentioned in the AI summary), this placeholder will need actual implementation before the backend is functional.

Would you like me to generate a database connection setup implementation? I can provide examples for common databases (PostgreSQL, MySQL, SQLite) with SQLAlchemy or async database connections.

backend/app/core/__init__.py (1)

1-1: Consider removing the placeholder comment or exposing the settings module.

This comment-only __init__.py is not idiomatic. Since the core package includes configuration (backend/app/core/config.py mentioned in the AI summary), you could optionally expose the settings instance for convenient imports.

Apply this diff to make it an empty file:

-# core package init

Or, to expose the settings instance:

from app.core.config import settings

__all__ = ["settings"]
backend/app/models/__init__.py (1)

1-1: Consider removing the placeholder comment.

This comment-only __init__.py is not idiomatic Python. The file should either be empty or, when database models are added later, contain imports to expose them at the package level.

Apply this diff to make it an empty file:

-# models package init
backend/app/db/__init__.py (1)

1-1: Consider removing the placeholder comment.

This comment-only __init__.py is not idiomatic Python. The file should either be empty or, when the database connection is implemented in database.py, contain imports to expose database utilities.

Apply this diff to make it an empty file:

-# db package init
backend/app/api/__init__.py (1)

1-1: Consider removing the placeholder comment.

This comment-only __init__.py is not idiomatic Python. The file should either be empty or, when API routes are added, contain imports to expose the router at the package level.

Apply this diff to make it an empty file:

-# api package init
backend/app/core/config.py (1)

5-6: Consider adding Field validators and defaults for robustness.

The current configuration will crash if environment variables are missing. Consider adding validation and informative error messages.

+from pydantic import Field
 from pydantic_settings import BaseSettings


 class Settings(BaseSettings):
-    database_url: str
-    ai_api_key: str
+    database_url: str = Field(
+        ...,
+        description="PostgreSQL connection string",
+        pattern=r"^postgresql://.*"
+    )
+    ai_api_key: str = Field(
+        ...,
+        description="API key for AI service",
+        min_length=1
+    )

     model_config = {"env_file": ".env"}
backend/app/main.py (1)

9-9: Fix ambiguous quote character in comment.

The comment contains a typographic apostrophe (') instead of a standard ASCII apostrophe (').

Apply this diff:

-    allow_origins=["*"],  # later we'll restrict this to your frontend URL
+    allow_origins=["*"],  # later we'll restrict this to your frontend URL
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b69f3d and 18ed6dd.

📒 Files selected for processing (13)
  • backend/.env (1 hunks)
  • backend/README.md (1 hunks)
  • backend/app/__init__.py (1 hunks)
  • backend/app/api/__init__.py (1 hunks)
  • backend/app/api/routes/__init__.py (1 hunks)
  • backend/app/core/__init__.py (1 hunks)
  • backend/app/core/config.py (1 hunks)
  • backend/app/db/__init__.py (1 hunks)
  • backend/app/db/database.py (1 hunks)
  • backend/app/main.py (1 hunks)
  • backend/app/models/__init__.py (1 hunks)
  • backend/env_example (1 hunks)
  • backend/requirements.txt (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-05-07T21:28:06.358Z
Learnt from: muntaxir4
Repo: AOSSIE-Org/InPactAI PR: 56
File: Backend/app/services/redis_client.py:1-4
Timestamp: 2025-05-07T21:28:06.358Z
Learning: Hardcoded Redis connection parameters in Backend/app/services/redis_client.py are intentional during development, with plans to implement environment variable configuration later during production preparation.

Applied to files:

  • backend/.env
🪛 dotenv-linter (4.0.0)
backend/.env

[warning] 3-3: [UnorderedKey] The AI_API_KEY key should go before the DATABASE_URL key

(UnorderedKey)

🪛 Ruff (0.14.2)
backend/app/main.py

9-9: Comment contains ambiguous (RIGHT SINGLE QUOTATION MARK). Did you mean ``` (GRAVE ACCENT)?

(RUF003)

🔇 Additional comments (5)
backend/env_example (1)

1-2: LGTM!

The example environment file provides clear templates for the required configuration variables and is appropriately named to avoid confusion with the actual .env file.

backend/app/main.py (1)

15-17: LGTM!

The root endpoint provides a clear welcome message and serves as a good health check for the backend.

backend/requirements.txt (3)

21-21: The review comment is incorrect. Version 4.15.0 is the latest available version of typing_extensions on PyPI. The dependency version specified in the requirements.txt file is current and valid.

Likely an incorrect or invalid review comment.


4-4: No action needed—version 25.9.0 is valid and current.

Black has transitioned to version 25.x.x versioning (likely for 2025). The latest available version of Black on PyPI is 25.9.0, confirming that this is the correct, up-to-date version.


1-22: No security vulnerabilities detected in pinned dependency versions.

Verification confirms all checked packages (fastapi, pydantic, uvicorn, starlette) are at safe versions. Notably, starlette==0.49.1 is the patched version addressing a HIGH severity O(n^2) DoS vulnerability that existed in 0.49.0.

@Saahi30
Copy link
Contributor Author

Saahi30 commented Nov 1, 2025

@CodeRabbit review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 1, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
.gitignore (2)

1-2: Redundant .vscode ignore entries.

Line 2 adds .vscode/ which overlaps with the existing .vscode/* pattern at line 21. In gitignore, both will ignore the directory, so one can be removed.

Remove the redundant entry at line 2:

-# Ignore VS Code settings
-.vscode/

The existing .vscode/* pattern at line 21 (along with the !.vscode/extensions.json exception) already handles VS Code ignores appropriately.

Also applies to: 21-21


40-40: Non-standard Python cache directory pattern.

Line 40 adds pycache/, but the correct Python convention is __pycache__/ (with double underscores on both sides), which already exists at line 32. The pycache/ pattern does not correspond to any standard Python cache directory.

Remove the non-standard entry:

-pycache/
backend/requirements.txt (1)

14-14: Pin the pydantic-settings version for reproducible builds.

The pydantic-settings dependency uses a flexible >=2.0.3 constraint while all other 22 dependencies use exact pins (==). This inconsistency reduces build reproducibility—different environments may install different versions of pydantic-settings and encounter unexpected behavior.

For consistency and determinism, pin it to a specific version compatible with Pydantic 2.12.3.

Apply this diff:

-pydantic-settings>=2.0.3
+pydantic-settings==2.6.1

This pins to version 2.6.1, which is verified compatible with the Pydantic 2.12.3 and pydantic_core 2.41.4 already specified.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18ed6dd and cde8a62.

📒 Files selected for processing (5)
  • .gitignore (2 hunks)
  • backend/app/core/config.py (1 hunks)
  • backend/app/main.py (1 hunks)
  • backend/env_example (1 hunks)
  • backend/requirements.txt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • backend/env_example
  • backend/app/core/config.py
  • backend/app/main.py
🔇 Additional comments (3)
.gitignore (2)

42-44: Good: Environment file ignores.

The additions of .env and backend/.env are appropriate for protecting sensitive configuration. This aligns with the backend configuration setup that loads environment variables from .env files.


46-47: Good: Next.js build directory ignore.

The addition of .next/ is appropriate for Next.js projects and prevents committing build artifacts.

backend/requirements.txt (1)

13-15: No changes required — pydantic versions verified compatible.

pydantic 2.12.3 is intended to be used with pydantic-core 2.41.x, confirming pydantic_core 2.41.4 is compatible; pydantic-settings 2.6.1 (and by extension >=2.0.3) works with Pydantic v2. The specified versions are compatible and work together as a cohesive unit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant